<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <title>Data数据管理系统后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
</head>

<body>
    <header class="navbar-wrapper" id="header">

    </header>
    <!--_menu 作为公共模版分离出去-->
    <aside class="Hui-aside" id="menu">

    </aside>
    <div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a>
    </div>
    <!--/_menu 作为公共模版分离出去-->

    <section class="Hui-article-box">
        <nav class="breadcrumb"><i class="Hui-iconfont"></i> <a href="../index.html" class="maincolor">首页</a>
            <span class="c-999 en">&gt;</span>
            <span class="c-666">栏目管理</span>
            <span class="c-999 en">&gt;</span>
            <span id="mbx"></span>
            <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
        </nav>
        <div class="Hui-article">
            <article class="cl pd-20" style="min-width: 900px; max-width: 90%;">
                <div class="cl pd-5 bg-1 bk-gray">
                    <span class="l">
                        <a class="btn btn-primary radius" href="javascript:void(0);"
                            onclick="class_add('添加栏目','add.html','800','500')">
                            <i class="Hui-iconfont">&#xe600;</i>添加栏目</a>
                    </span>
                    <!-- <span class="l">
                        <a href="javascript:;" onclick="del_all()" class="btn btn-danger radius">
                            <i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
                        <a class="btn btn-primary radius" href="{:url('/edataclass/add')}">
                            <i class="Hui-iconfont">&#xe600;</i> 添加数据表</a>
                    </span> -->
                    <span class="r">共有数据：
                        <strong id="counts">-</strong> 条</span>
                </div>
                <div class="mt-10">
                    <table class="table table-border table-bordered table-hover table-bg">
                        <thead>
                            <tr class="text-c">
                                <th width="25px">
                                    <input type="checkbox" value="" name="">
                                </th>
                                <th width="60px">ID</th>
                                <!-- <th width="60px">父ID</th> -->
                                <th width="180px">表(栏目)名称</th>
                                <th width="220px">tablename</th>
                                <th width="100px">添加时间</th>
                                <th width="60px">点击量</th>
                                <th width="100px">备注</th>
                                <th width="80px">操作</th>
                            </tr>
                        </thead>
                        <tbody id="liebiao_box">

                        </tbody>
                    </table>
                </div>
            </article>
        </div>
    </section>

    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.page.js"></script>
    <script type="text/javascript" src="../static/js/admin.js"></script>
    <!--/_footer /作为公共模版分离出去-->

    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="../static/js/header.js?123"></script>
    <script type="text/javascript" src="../static/js/menu.js?123"></script>
    <script type="text/javascript">
        $.ajax({
            url: "/ajax/class/getdataclasstree",
            type: "GET",
            data: null,
            beforeSend: function (request) {
                request.setRequestHeader("authStr", window.localStorage.getItem("userId") + "-" + window
                    .localStorage.getItem("token"));
            },
            success: function (data) {
                if (data.success == true) {
                    // console.log(data.data);
                    edataclass = data.data;
                    var liebiao_str = "";
                    /*计算栏目条数*/
                    var count_tr = 0;
                    edataclass.forEach(eclass => {
                        liebiao_str += '<tr class="text-c">';
                        liebiao_str += '<td><input type="checkbox" value="' + eclass.id +
                            '" name="checkbox[]"></td>';
                        liebiao_str +=
                            '<td class="text-l"><a href="javascript:void(0);" onclick="loader(this);" data-status="0"><i class="icon Hui-iconfont">&#xe610;</i><span>' +
                            eclass.id + '</span></a></td>';
                        liebiao_str += '<td class="text-l">' + eclass.classname + '</td>';
                        liebiao_str += '<td class="text-l">' + eclass.tablename + '</td>';
                        liebiao_str += '<td>' + eclass.ctime + '</td>';
                        liebiao_str += '<td>' + eclass.onclick + '</td>';
                        liebiao_str += '<td>' + eclass.note + '</td>';
                        liebiao_str += '<td class="f-14">';
                        liebiao_str +=
                            '<a title="编辑" href="javascript:;" onclick="class_edit(\'编辑数据表信息\',\'add.html\',' +
                            eclass.id +
                            ',\'800\',\'500\')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>';
                        liebiao_str +=
                            '<a title="删除" href="javascript:;" onclick="class_del(this,' + eclass
                            .id +
                            ')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
                        liebiao_str += '</td>';
                        liebiao_str += '</tr>';
                        // console.log(eclass.children);
                        eclass.children.forEach(function (ecl) {
                            // console.log(ecl);
                            liebiao_str += '<tr class="text-c parent_' + eclass.id +
                                ' son" style="display:none;">';
                            liebiao_str += '<td><input type="checkbox" value="' + ecl.id +
                                '" name="checkbox[]"></td>';
                            liebiao_str +=
                                '<td><a href="javascript:void(0);" onclick="loader(this);" data-status="0"><i class="icon Hui-iconfont">&#xe610;</i><span>' +
                                ecl.id + '</span></a></td>';
                            liebiao_str += '<td class="text-l">' + ecl.classname + '</td>';
                            liebiao_str += '<td class="text-l">' + ecl.tablename + '</td>';
                            liebiao_str += '<td>' + ecl.ctime + '</td>';
                            liebiao_str += '<td>' + ecl.onclick + '</td>';
                            liebiao_str += '<td>' + ecl.note + '</td>';
                            liebiao_str += '<td class="f-14">';
                            liebiao_str +=
                                '<a title="编辑" href="javascript:;" onclick="class_edit(\'编辑数据表信息\',\'add.html\',' +
                                ecl.id +
                                ',\'800\',\'500\')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>';
                            liebiao_str +=
                                '<a title="删除" href="javascript:;" onclick="class_del(this,' +
                                ecl.id +
                                ')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
                            liebiao_str += '</td>';
                            liebiao_str += '</tr>';
                            ecl.children.forEach(function (e) {
                                liebiao_str += '<tr class="text-c parent_' + ecl
                                    .id + ' grandparent_' + eclass.id +
                                    ' grandson" style="display:none;">';
                                liebiao_str +=
                                    '<td><input type="checkbox" value="' + e.id +
                                    '" name="checkbox[]"></td>';
                                liebiao_str += '<td>' + e.id + '</td>';
                                liebiao_str += '<td class="text-l">' + e.classname +
                                    '</td>';
                                liebiao_str += '<td class="text-l">' + e.tablename +
                                    '</td>';
                                liebiao_str += '<td>' + e.ctime + '</td>';
                                liebiao_str += '<td>' + e.onclick + '</td>';
                                liebiao_str += '<td>' + e.note + '</td>';
                                liebiao_str += '<td class="f-14">';
                                liebiao_str +=
                                    '<a title="编辑" href="javascript:;" onclick="class_edit(\'编辑数据表信息\',\'add.html\',' +
                                    e.id +
                                    ',\'800\',\'500\')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>';
                                liebiao_str +=
                                    '<a title="删除" href="javascript:;" onclick="class_del(this,' +
                                    e.id +
                                    ')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
                                liebiao_str += '</td>';
                                liebiao_str += '</tr>';
                                count_tr++;
                            });
                            count_tr++;
                        });
                        count_tr++;
                    });
                    $("#liebiao_box").append(liebiao_str);
                    $("#counts").text(count_tr - 1);
                }
            }
        });

        function loader(obj) {
            var id = $(obj).children('span').text();
            var status = $(obj).data('status');
            // console.log(status);

            if (status == 1) {
                $(".parent_" + id).css('display', 'none');
                $(".grandparent_" + id).css('display', 'none');
                $(obj).children('img').attr('src', '../static/images/add.gif')
                $(obj).data('status', 0);
                $(".parent_" + id).children('td').children('.category').data('status', 0);
                return false;
            }
            $(".parent_" + id).css('display', '');
            $(obj).children('img').attr('src', '../static/images/subtract.gif')
            $(obj).data('status', 1);

            return false;
        }

        function class_add(title, url, w, h) {
            url = url + '?action=add';
            layer_show(title, url, w, h);
        }

        function class_edit(title, url, id, w, h) {
            url = url + '?action=edit&id=' + id;
            layer_show(title, url, w, h);
        }

        function class_del(obj, id) {
            layer.confirm('确认要删除吗？', function (index) {
                //此处请求后台程序，下方是成功后的前台处理……
                $.ajax({
                    type: "POST",
                    url: "/ajax/class/delete",
                    data: {
                        "id": id
                    },
                    dataType: "json",
                    beforeSend: function (request) {
                        request.setRequestHeader("authStr", window.localStorage.getItem("userId") +
                            "-" + window.localStorage.getItem("token"));
                    },
                    success: function (data) {
                        if (data.success == true) {
                            $(obj).parents("tr").remove();
                            layer.msg(data.msg, {
                                icon: 6,
                                time: 2000
                            });
                        } else {
                            layer.msg(data.msg, {
                                icon: 5,
                                time: 2000
                            });
                        }
                        return false;
                    },
                    error: function (e) {
                        layer.msg("请求出错, 请稍后重试", {
                            icon: 5,
                            time: 2000
                        })
                    }
                });
            });
        }

        // /*展开所有栏目*/
        // function load_all() {
        //     $('.son').toggle();
        //     $('.grandson').toggle();
        // }
    </script>
    <!--/请在上方写此页面业务相关的脚本-->

</body>

</html>